<!--
 * @Author: your name
 * @Date: 2023-08-15 22:30:42
 * @LastEditTime: 2023-08-16 23:24:21
 * @LastEditors: your name
 * @Description: 
-->
<template>
  <div class="screen-right-1">
    <div class="chart-pie" ref="chartRef"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  data() {
    return {
      myChart: null,
    };
  },
  created() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  methods: {
    initChart() {
      this.myChart = echarts.init(this.$refs.chartRef);

      let option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          textStyle: {
            color: "rgba(255, 255, 255, 1)",
          },
          orient: "vertical",
          right: "5%",
          top: "10%",
          // formatter: function (name) {
          //   return "Legend " + name;
          // },
          type: 'scroll',
        },
        series: [
          {
            name: "事故管理",
            type: "pie",
            radius: ["50%", "80%"],
            center: ["30%", "50%"],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 2,
            },
            label: {
              show: true,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                // fontSize: 18,
                // fontWeight: "bold",
              },
            },
            labelLine: {
              show: true,
            },
            data: [
              { value: 1048, name: "管理制度" },
              { value: 735, name: "事故台账" },
              { value: 580, name: "事故调查报告" },
              { value: 484, name: "事故处理资料" },
              { value: 1048, name: "管理制度2" },
              { value: 735, name: "事故台账2" },
              { value: 580, name: "管理制度3" },
              { value: 484, name: "管理制度4" },
            ],
          },
        ],
      };

      this.myChart.setOption(option);
    },
  },
};
</script>

<style lang="scss">
.screen-right-1 {
  width: 100%;
  height: 100%;
  padding: 8vh 1vh 1vh;
  box-sizing: border-box;
  .chart-pie {
    width: 90%;
    margin: 0 auto;
    height: 100%;
  }
}
</style>